package banxi.ktv.hdao.song;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Hibernate;
import org.hibernate.Session;

import banxi.ktv.domain.Song;
import banxi.ktv.hdao.HibernateHelper;

public class SongDaoImpl implements SongDao {
	private static final Log log = LogFactory.getLog(SongDaoImpl.class);
	private Session session = HibernateHelper.getSession();
	

	public void persist(Song song) {
		session.beginTransaction();
		session.persist(song);
		session.getTransaction().commit();
	}

	public Song findById(int id) {
		Song song = (Song) session.get(Song.class, id);
		if(song == null){
			log.error("查询失败.Song :id"+id);
		}
		return song;
	}

}
